package com.example.demo.controller;

import com.example.demo.admin.dto.SearchDto;
import com.example.demo.admin.pojo.PageResult;
import com.example.demo.admin.pojo.Result;
import com.example.demo.service.JobService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/job")
public class JobController {

    @Autowired
    private JobService jobService;
    //获取全部职业信息
    @GetMapping()
    public Result<PageResult> getAllJob(SearchDto searchDto){
        log.info("获取部门全部信息{}",searchDto);
        PageResult pageResult = jobService.getAllJob(searchDto);
        return Result.success(pageResult);
    }
    //删除职业信息
    @DeleteMapping()
    public Result deleteJob(Long id){
        log.info("删除职业{}",id);
        jobService.deleteJobById(id);
        return Result.success();
    }

    //添加职业
    @PostMapping("/{name}")
    public Result addJob(@PathVariable String name){
        log.info("添加参数{}",name);
        jobService.addJob(name);
        return Result.success();
    }

    //编辑职业
    @PutMapping("/{id}/{name}")
    public Result editJob(@PathVariable String name,@PathVariable Long id){
        log.info("编辑参数{}{}",name,id);
        jobService.editJob(name,id);
        return Result.success();
    }
}
